package com.chinaoly.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chen.helper.LightRecycleViewHelper;
import com.chen.helper.widget.SimpleDividerDecoration;

import java.util.ArrayList;
import java.util.List;

public class CommonRecyActivity extends AppCompatActivity {

    LightRecycleViewHelper<String> helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_recy);
       setData();

    }

    private void setData() {
        RecyclerView rv = findViewById(R.id.rv);
        List<String> a = new ArrayList<>();
        a.add("a");
        a.add("a");
        a.add("a");
        a.add("a");
        a.add("a");
        a.add("a");
        a.add("a");
        a.add("a");
        rv.addItemDecoration(new SimpleDividerDecoration(this));
        helper = new LightRecycleViewHelper<String>(R.layout.item_refresh, rv) {

            @Override
            protected void setItemData(BaseViewHolder helper, String item) {
                helper.setText(R.id.tv_input, item);
            }
        };
        helper.setListData(a);
        helper.getAdapter().setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

            }
        });
    }
}
